package co.fitstart.admin.entity.search;

import java.util.Map;

import com.demo2do.core.persistence.support.Filter;
import com.demo2do.core.persistence.support.Order;
import com.demo2do.core.persistence.support.QueryBuilder;


/**
 * 
 * @author Wy
 *
 */
public class MovementSearch implements QueryBuilder{
    
	/** 动作名称 */
	private String name;
	
	/** 动作类别 */
	private Long categoryId;
	 
	/** 动作器材 */
	private Long equipmentId;
	
    private Order order;
    
    private Filter filter;
    
    /**
     * default constructor
     */
	public MovementSearch() {
		
	}

	/*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
	public Filter getPreparedFilter(boolean refresh) {
		 if(filter == null || refresh) {
			 filter =new Filter().addLike("movement.name", name)
					             .addEquals("movement.category.id",categoryId)
					             .addEquals("movement.equipment.id",equipmentId);
		 }
		return filter;
	}

	
	/*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
	public Order getOrder() {
		return order;
	}

	/*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
	public String buildSentenceTemplate() {
		return "FROM Movement movement WHERE movement.disabled = false " + getPreparedFilter(false).getClauseSentence();
	}

	/*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
	public Map<String, Object> buildParameters() {
		return getPreparedFilter(false).getParameters();
	}

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the categoryId
     */
    public Long getCategoryId() {
        return categoryId;
    }

    /**
     * @return the equipmentId
     */
    public Long getEquipmentId() {
        return equipmentId;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param categoryId the categoryId to set
     */
    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    /**
     * @param equipmentId the equipmentId to set
     */
    public void setEquipmentId(Long equipmentId) {
        this.equipmentId = equipmentId;
    }


	
	
}
